import { getItem, setItem } from "@/util/storage"
import { Token_Timeout_Value } from "@/config"

// 时间戳key
const TIME_STAMP = "timeStamp"

/**
 * 获取时间戳
 */
export function getTimeStamp () {
  return getItem(TIME_STAMP)
}

/**
 * 设置时间戳
 */
export function setTimeStamp () {
  setItem(TIME_STAMP, Date.now())
}

/**
 * 是否超时
 */
export function isCheckTimeout () {
  // 当前时间
  const currentTime = Date.now()
  // 缓存时间
  const timeStamp = getTimeStamp()

  return currentTime - timeStamp > Token_Timeout_Value
}
